//
//  ViewController.m
//  ControlFun
//
//  Created by student on 16/2/18.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIAlertViewDelegate,UIActionSheetDelegate> 

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)backtap:(id)sender
{
    [self.view endEditing:YES];
}

- (IBAction)segementchaged:(UISegmentedControl *)sender
{
   if(sender.selectedSegmentIndex==0)
   {
       self.leftSwitch.hidden=NO;
       self.rightSwitch.hidden=NO;
       self.dosomethingbutton.hidden=YES;
   }
    
   else
   {
       self.leftSwitch.hidden=YES;
       self.rightSwitch.hidden=YES;
       self.dosomethingbutton.hidden=NO;
   }
    
}

- (IBAction)switchchanged:(UISwitch *)sender
{
    BOOL open=sender.on;
    [self.leftSwitch setOn:open animated:YES];
    [self.rightSwitch setOn:open animated:NO];
}

- (IBAction)dosomethingbuttonpressed:(UIButton *)sender
{
   
    UIActionSheet *sheet=[[UIActionSheet alloc]initWithTitle:@"弹出" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:nil];
    [sheet showInView:self.view];
    
    
    
}

- (IBAction)sliderchanged:(UISlider *)sender
{
    int value=sender.value;
    self.sliderValueLable.text=[NSString stringWithFormat:@"%i",value];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(buttonIndex == actionSheet.destructiveButtonIndex)
    {
        NSString *string=[self.nameTextField.text stringByAppendingString:@"加油啊"];
        UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"弹出" message:(@"%@",string) delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alertView show];
    }
    
    
    
}
@end
